package com.bw.liveplay.common.mvvm.view.fragment

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.viewpager.widget.ViewPager
import com.bw.liveplay.R
import com.bw.liveplay.common.mvvm.adapter.ViewPagerAdapter
import com.bw.liveplay.common.mvvm.view.findfragment.ImgFragment
import com.bw.liveplay.common.mvvm.view.findfragment.TextFragment
import com.bw.liveplay.common.mvvm.view.findfragment.VideoFragment
import com.flyco.tablayout.SlidingTabLayout

/**
 * @author KK
 * @description:
 * @date :2021/11/10 15:20
 *
 */
class FindFragment : Fragment(){
    private var findTab: SlidingTabLayout?= null
    private var findVip :  ViewPager?=null
    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {

        var inflate = inflater.inflate(R.layout.fragment_find, container, false)

        findTab = inflate!!.findViewById(R.id.find_tab);
        findVip =  inflate!!.findViewById(R.id.find_vip);
        var imgFragment: ImgFragment = ImgFragment()
        var videoFragment: VideoFragment = VideoFragment()
        var textFragment: TextFragment = TextFragment()

        var fragments :ArrayList<Fragment> = ArrayList()
        fragments!!.add(imgFragment)
        fragments!!.add(videoFragment)
        fragments!!.add(textFragment)
        var arr = arrayOf("图片","视频","文本")
        var adapter : ViewPagerAdapter = ViewPagerAdapter(childFragmentManager)
        adapter.list = fragments
        findVip!!.adapter = adapter
        findTab!!.setViewPager(findVip,arr)
        return inflate

    }

}